//
//  XPNetErrorTipView.swift
//  MTInternational
//
//  Created by xiaopin on 2020/9/12.
//  Copyright © 2020 scoresdata.net. All rights reserved.
//

import UIKit

/// 网络错误提示小部件,导航栏下面提示
class XPNetErrorTipView: XPBaseView {

    //MARK: 属性
    let iconImage = UIImageView(imageName: "icon_wwl")
    let textLabel = UILabel(14, weight: .regular, textColor: pp_color(.C555555), text: "网络连接失败，请检查网络设置。", align: .left)
    let arrowImage = UIImageView(imageName: "arrow_right_black")
    let button = UIButton(target: self, action: #selector(clickAction))
    
    var clickClosure:(()->())?
    
    //MARK: 重载父类方法
    /// 初始化当前视图的子控件
    override func initSubViews() {
        self.backgroundColor = pp_color("FFDBDB", "DC463C")
   
        iconImage.beAddInto(self).snp.makeConstraints { m in
            m.left.equalTo(15.scale)
            m.width.height.equalTo(20.scale)
            m.centerY.equalToSuperview()
        }
        
        textLabel.beAddInto(self).snp.makeConstraints { m in
            m.left.equalTo(45.scale)
            m.right.equalTo(-45.scale)
            m.centerY.equalToSuperview()
        }
        arrowImage.beAddInto(self).snp.makeConstraints { m in
            m.width.equalTo(10)
            m.height.equalTo(12)
            m.right.equalTo(-15.scale)
            m.centerY.equalToSuperview()
        }
        
        button.beAddInto(self).snp.makeConstraints { m in
            m.width.height.top.bottom.equalToSuperview()
        }
    }
    
    //MARK: 自定义方法
    
    //MARK: 事件通知
    func clickAction(){
        if let closure = self.clickClosure {
            closure()
        }
    }
}
